package com.chenshu.mycnblog.common;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA
 * Description：异常类的统一处理
 * User：chenshu
 * Date：2024-01-02
 * Time：23:56
 */
@ControllerAdvice
@ResponseBody
public class ExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public Object handler(Exception e) {
        return MyResponse.fail(-1, e.getMessage());
    }
}
 